import { getSongList, getSongListByPage } from '@/fetch/song'
import { ISongItem } from '@/fetch/type'
import { defineStore } from 'pinia'

export const useSong = defineStore('song', {
  persist: true,
  state: () => {
    return {
      currentSong: {} as ISongItem,
      songList: [] as ISongItem[],
      pageSongList: [] as ISongItem[]

    }
  },
  actions: {
    async getAllSong() {
      const songs = await getSongList()
      this.songList = songs.data.data
    },
    async getSongByPage() {
      const songs = await getSongListByPage({ page: 1, pageSize: 10 })
      this.pageSongList = songs.data.data.records
    }
  }
})